<script>
function start_game() {
var size = document.getElementById('size').value;
document.getElementById('output_message').innerHTML = 'If you expect everything, you will get everything.';
_TWTG_initialize(size);
}
</script>
...
Size: <input id='size' type='number' min='2' max='5' value='3'></input>
<button id='start_button' onclick='start_game()'>Start the game</button>
<p id='output_message'></p>
...
var course = ['comp2680', 'comp3540', 'comp4620'];
var person = {fname:"John", lname:"Doe", age:25};
var text = "";
var x;
for (x in person)
text += person[x] + ', ';
text += '<br>';
for (x in course)
text += course[x] + ', ';
text += '<br>';
person[0] = 'comp2680';
person[1] = 'comp3540';
person[2] = 'comp4620';
for (x in person)
text += person[x] + ', ';
window.alert(text);
function toCelsius(f) { return 5 / 9 * (f - 32); }
temp = toCelsius;
document.write(temp(66));
var person = {
firstName:"John",
lastName:"Doe",
age:50,
eyeColor:"blue",
getFullName: function() { return this.firstName + " " + this.lastName; }
};
document.write(person.age + '<br>');
document.write(person['age'] + '<br>'); // Objects behave like arrays, and arrays are objects.
document.write(person.fullName() + '<br>');
document.write(person['getFullName']() + '<br>'); // Objects behave like arrays, and arrays are objects.
var str = ' Amazing Spiderman! \n';
alert('**' + str + '**');
str = str.trim();
alert('**' + str + '**');
<!DOCTYPE html>
<head>
<style>
/* CSS rules to style the HTML elements in the body element. */
</style>
<script>
// Variables
// Control statement, such as assignment, if-else, for, for/in, while, do-while, switch, function invokation statements
// Functions
// Functions (event handlers)
// Invoked when events are triggered on HTML elements in the body element
// Control HTML elements in the body element
</script>
</head>
<body>
<!-- HTML elements -->
<!-- Some HTML elements have ids. -->
<!-- Some HTML elements have onclick='javascript code'. -->
</body>